#!/bin/sh

dockerid=`docker ps -a --no-trunc --filter name=mysql| grep -v CONTAINER | awk '{print $1}'`

if [[ -n "$dockerid" ]]; then
    docker stop $dockerid && docker rm $dockerid
fi

docker run -d --name mysql \
 -p 3306:3306 --privileged=true \
 --restart=always \
 -m 256Mi \
 --memory-reservation 128Mi \
 --cpus 0.1 \
 -v /opt/mysql/log:/var/log/mysql \
 -v /opt/mysql/data:/var/lib/mysql \
 -v /opt/mysql/conf:/etc/mysql/conf.d \
 -v /etc/mysql/conf.d/my.cnf:/etc/mysql/conf.d/my.cnf \
 -e MYSQL_ROOT_PASSWORD=root_123 \
  mysql:5.7
